<template>
	<view class="container">
		<tn-nav-bar fixed  :isBack="true" >
			下载APP		
		</tn-nav-bar>
		<view class="wx" v-if="isShow"  :style="{paddingTop: vuex_custom_bar_height + 'px'}">
			<image :src="calcImageSrc('wx.png')" class="wx-image" mode="aspectFit"></image>
		</view>
		<!--插画-->
		<view class="right-top-sign" :style="{paddingTop: vuex_custom_bar_height + 'px'}"></view>
		<view class="wrapper" >
			<view class="left-top-sign">{{configInfo.shoname}}</view>

			<view class="text-title">
				<view style="display: flex;flex-direction: row;align-items: center;">
					<image :src="configInfo.site_logo" class="logo-image" mode="widthFix"></image>
					<text>{{configInfo.shoname}}</text>
				</view>

				<view class="text-slogan">
					{{configInfo.slogan}}
				</view>
			</view>
			<view class="flex-col">
				<image :src="configInfo.qrcodeUrl" mode="aspectFit"></image>

				<view class="btn" @click="down('android')">
					<image :src="calcImageSrc('and.png')" mode="aspectFit"></image>
					<view class="text">
						<view>Android版</view>
						<view>立即下载</view>
					</view>
				</view>
				
				<view class="btn" @click="down('ios')">
					<image :src="calcImageSrc('ios.png')" mode="aspectFit"></image>
					<view class="text">
						<view>苹果ios版</view>
						<view>立即下载</view>
					</view>
				</view>
				
			</view>

		</view>


		<text class="text-copyright">Copyright © {{(new Date).getFullYear()}} {{configInfo.shoname}} All rights reserved.
		</text>
	</view>
</template>
<script>
	export default {

		data() {
			return {
				weixin: false, //是否为微信内浏览器打开
				isShow: false,
				config: {}

			};
		},
		onLoad() {
			// 判断该页面是否为微信内置浏览器内打开 true>显示浏览器内打开引导
			this.isWX()

		},
		methods: {


			
			isWX() {
				let ua = navigator.userAgent.toLowerCase();
				if (ua.match(/MicroMessenger/i) == "micromessenger") {
					this.weixin = true
				} else {
					this.weixin = false
				}
			},

			down(type) {
				
				if (this.weixin) {
					uni.showModal({
						content: '请点击右上角按钮\n选择在浏览器打开',
						showCancel: false,

					});

					this.isShow = true;
				} else {
					if (type == 'android') {
						
						if (!this.configInfo.app_android){
							this.msg('暂无下载地址')
							return
						}
						
						// #ifdef H5
						window.location.href = this.configInfo.app_android;
						// #endif

						// #ifdef MP-WEIXIN

						this.download(this.configInfo.app_android)

						// #endif

					} else {
						if (!this.configInfo.app_ios){
							this.msg('暂无下载地址')
							return
						}
						 window.open(this.configInfo.app_ios);
					}
				}

			},
			download(openUrl) {
				uni.showLoading({
					title: '正在下载...',
					mask: false
				});
				uni.downloadFile({
					url: openUrl,
					success: function(res) {
						uni.hideLoading();
						console.log(res);
						var filePath = res.tempFilePath;

						uni.openDocument({
							filePath: filePath,
							showMenu: true,
							success: function(res) {}
						});
					}
				});
			},
		}
	}
</script>
<style lang="scss">
	page {
		background: #FFFFFF;
	}

	.container {
		padding-top: 80px;
		position: relative;
		width: 100vw;
		overflow: hidden;
		background: #fff;

		.wrapper {
			position: relative;
			z-index: 90;
			background: #fff;
			padding-bottom: 40rpx;
		}



		.left-top-sign {
			font-size: 120rpx;
			color: #f8f8f8;
			position: relative;
			left: -16rpx;
		}

		.right-top-sign {
			position: absolute;
			top: 80rpx;
			right: -30rpx;
			z-index: 95;

			&:before,
			&:after {
				display: block;
				content: '';
				width: 400rpx;
				height: 80rpx;
				background: #3BB1E3;
			}

			&:before {
				transform: rotate(50deg);
				border-radius: 0 50px 0 0;
			}

			&:after {
				position: absolute;
				right: -198rpx;
				top: 0;
				transform: rotate(-50deg);
				border-radius: 50px 0 0 0;
			}
		}



		.text-title {
			position: relative;
			left: 50rpx;
			top: -80rpx;
			font-weight: bold;
			font-size: 46rpx;
			color: #555;
			text-shadow: 1px 0px 1px rgba(0, 0, 0, 0.3);
		}

		.text-slogan {
			font-size: 32rpx;
			margin-top: 10rpx;
			margin-left: 110rpx;
			font-weight: normal;
			color: #999;
			text-shadow: 1px 0px 1px rgba(0, 0, 0, 0.3);
		}

		.flex-col {
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;

			image {
				width: 250px;
				height: 250px;
			}
		}

		.btn {
			display: flex;
			flex-direction: row;
			align-items: center;
			background-color: #037EFF;
			border-radius: 20rpx;
			color: #FFFFFF;
			padding: 20rpx 30rpx;
			margin-top: 60rpx;
			background: linear-gradient(to bottom, #3BB1E3 0%, #037EFF 100%);
			border-bottom: 4px solid #2076c6;
			text-shadow: 1px 1px 1px rgba(0, 0, 0, .4);
			box-shadow: 0px 3px 0px 0px rgba(0, 0, 0, .1);

			image {
				width: 60rpx;
				height: 60rpx;

			}

			.text {
				margin-left: 20rpx;
				font-weight: bold;

				view:nth-child(1) {

					font-size: 34rpx;
				}

				view:nth-child(2) {
					font-size: 28rpx;
				}
			}
		}

		.btn:active {
			box-shadow: 0px 2px 0px 0px rgba(0, 0, 0, .2);
			opacity: 0.9;
			transform: translate(1rpx, 1rpx);
		}


		.text-copyright {
			color: #bebebe;
			font-size: 24rpx;
			left: 0;
			position: fixed;
			bottom: 0;
			text-align: center;
			width: 100%;
			margin-bottom: 30rpx;

		}


		.wx {
			position: fixed;
			left: 0;
			top: 0;
			background-color: rgba(0, 0, 0, .7);
			width: 100vw;
			height: 100vh;
			z-index: 99;

		}

		.wx-image {
			position: absolute;
			right: 0;
			top: 0;
			margin-right: 20rpx;
		}

		.logo-image {
			width: 90rpx;
			margin-right: 20rpx;
		}
	}
</style>
